package model

import (
	"time"
)

type Meal struct{
	MealId int `xorm:"pk autoincr"`
	MealName string
	Price int64
	Number int64
	CreatedAt time.Time
	UpdatedAt time.Time
}

func (m *Meal)QueryMealList(soId int) []*Meal{
	var mvList []*Meal
	err := x.Join("INNER","single_order_meal", "single_order_meal.meal_id = meal.meal_id").Where("single_order_id = ?", soId).Find(&mvList)
	if err != nil{
		return nil
	}
	return mvList
}

func (m *Meal)QueryMealListMonth(moId int) []*Meal{
	var mvList []*Meal
	err := x.Join("INNER","monthly_order_meal", "monthly_order_meal.meal_id = meal.meal_id").Where("monthlysingle_order_id = ?", moId).Find(&mvList)
	if err != nil{
		return nil
	}
	return mvList
}

func (m *Meal)QueryMealListYear(aoId int) []*Meal{
	var mvList []*Meal
	err := x.Join("INNER","accumulative_order_meal", "accumulative_order_meal.meal_id = meal.meal_id").Where("accumulative_order_id = ?", aoId).Find(&mvList)
	if err != nil{
		return nil
	}
	return mvList
}